package com.kaifamiao.modern;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

public class LocalDateTimeTest3 {

	public static void main(String[] args) {
		
		LocalTime time = LocalTime.of(14, 45);
		
		LocalDate date = LocalDate.of(2021, 12, 31);
		
		// LocalTime ==> LocalDateTime
		LocalDateTime datetime = time.atDate(date);
		System.out.println(datetime);
		
		// LocalDate ==> LocalDateTime
		datetime = date.atStartOfDay();
		System.out.println( datetime );
		
		// LocalDate ==> LocalDateTime
		datetime = date.atTime( time );
		System.out.println( datetime );
		
		// LocalDate ==> LocalDateTime
		datetime = date.atTime( 23, 59, 59, 999999999 );
		System.out.println( datetime );
		
		LocalDateTime now = LocalDateTime.now();
		System.out.println( now );
		
		// LocalDateTime ==> LocalDate
		LocalDate localDate = now.toLocalDate();
		System.out.println( localDate );
		
		// LocalDateTime ==> LocalTime
		LocalTime localTime = now.toLocalTime();
		System.out.println( localTime );
		

	}

}
